package com.cts.training.mdb;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * Message-Driven Bean implementation class for: ResourceManagementMDB
 *
 */
@MessageDriven(
		activationConfig = { 
		@ActivationConfigProperty(
				propertyName = "destinationType", propertyValue = "javax.jms.Topic"
		)},
		mappedName="TrainingTopic")
public class ResourceManagementMDB implements MessageListener {

    /**
     * Default constructor. 
     */
    public ResourceManagementMDB() {
        // TODO Auto-generated constructor stub
    }
	
	/**
     * @see MessageListener#onMessage(Message)
     */
    public void onMessage(Message message) {
        // TODO Auto-generated method stub
        if (message instanceof TextMessage) {
			TextMessage msg = (TextMessage) message;
			try {
				String name =msg.getStringProperty("name");
				System.out.println("name is : "+name);
			} catch (JMSException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
        }
    }

}
